<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Exam extends CI_Controller {
	
	private $table;
	private $singleChoiceTable;
	private $dataAnalysisTable;
	
	
	public function __construct(){
		
		parent::__construct();
		
		$this->load->database();
		
		$this->table = $this->db->dbprefix('u_c_exam');
		$this->singleChoiceTable = $this->db->dbprefix('u_m_single_choice');
		$this->dataAnalysisTable = $this->db->dbprefix('u_m_data_analysis');
	}
	
	public function getExamName(){
		$sql = "SELECT classid,exam_name FROM {$this->table}";
		$result['exam'] = $this->db->query($sql)->result_array();
//		echo "<PRE>";
//		print_r($result);
//		exit();
		$this->load->view("examName",$result);
	}
	
	public function getExamById($id=0){
		$data = array();
		$where = "exam_category={$id}";
		
		$sql1 = "SELECT * FROM {$this->singleChoiceTable} WHERE {$where} AND category=13 ORDER BY category";
		$data['yynlyy'] = $this->db->query($sql1)->result_array();
		
		$sql2 = "SELECT * FROM {$this->singleChoiceTable} WHERE {$where} AND category=14 ORDER BY category";
		$data['ljpd'] = $this->db->query($sql2)->result_array();
		
		$sql3 = "SELECT * FROM {$this->singleChoiceTable} WHERE {$where} AND category=15 ORDER BY category";
		$data['slgx'] = $this->db->query($sql3)->result_array();
		
		$sql4 = "SELECT * FROM {$this->singleChoiceTable} WHERE {$where} AND category=16 ORDER BY category";
		$data['cspd'] = $this->db->query($sql4)->result_array();
		
		$sql5 = "SELECT * FROM {$this->dataAnalysisTable} WHERE {$where}";
		$data['zlfx'] = $this->db->query($sql5)->result_array();
		
		$data['answerArr'] = array(0=>'A',1=>'B',2=>'C',3=>'D');
		
//		echo '<PRE>';
//		print_r($data);
//		exit();
		$this->load->view('exam',$data);
	}
}